﻿using Autofac;
using Microsoft.AspNetCore.Mvc;

namespace MyApi.Filter
{
    /// <summary>
    /// 控制器中的属性注入功能
    /// </summary>
    public class AutofacPropertyModuleReg:Autofac.Module
    {
        /// <summary>
        /// 注入属性方法  没看到效果，就是属性注入还不能使用
        /// </summary>
        /// <param name="builder"></param>
        protected override void Load(ContainerBuilder builder)
        {
            var controllerBaseType = typeof(ControllerBase);
            builder.RegisterAssemblyTypes(typeof(Program).Assembly)
                //.Where(i => controllerBaseType.IsAssignableFrom(i) && i != controllerBaseType)
                .PropertiesAutowired();
             base.Load(builder);
        }
    }
}
